+++ /dev/null
-#! /bin/sh
-### BEGIN INIT INFO
-# Provides: tmpfs
-# Required-Start: $local_fs
-# Required-Stop: $local_fs
-# X-Start-Before: nginx
-# Default-Start: 2 3 4 5
-# Default-Stop: 0 1 6
-# Short-Description: Initialise tmpfs file systems
-### END INIT INFO
-
-PATH=/sbin:/usr/sbin:/bin:/usr/bin
-
-. /lib/init/vars.sh
-. /lib/lsb/init-functions
-
-do_start() {
- if [ -x /etc/rc.local ]
- then
- [ "$VERBOSE" != no ] && log_begin_msg "Initialising tmpfs file systems"
-
- ! mountpoint -q /run ||
- sudo install -d -m 770 -o www-data -g www-data \
- /run/nginx \
- /run/nginx/fastcgi
-
- if mountpoint -q /run/shm &&
- test -f /run/shm/.tmpfs
- then
- set -x
- sudo install -d -m 1777 -o root -g root \
- /run/shm/cache \
- /run/shm/tmp
-
- ! getent passwd www-data >/dev/null ||
- sudo install -d -m 770 -o www-data -g www-data \
- /run/shm/cache/nginx \
- /run/shm/cache/nginx/fastcgi \
- /run/shm/cache/nginx/client_body
-
- ! getent passwd php5 >/dev/null ||
- sudo install -d -m 1771 -o php5 -g php5 \
- /run/php5 \
- /run/php5/fpm \
- /run/shm/cache/php5 \
- /run/shm/cache/php5/fpm \
- /run/shm/tmp/php5
-
- ! getent passwd fcgi-gitweb >/dev/null ||
- sudo install -d -m 1771 -o fcgi-gitweb -g fcgi-gitweb \
- /run/shm/tmp/gitweb
-
- ! getent passwd mysql >/dev/null ||
- sudo install -d -m 1771 -o mysql -g mysql \
- /run/mysqld \
- /run/mysqld/sock
-
- ! getent passwd postgres >/dev/null ||
- sudo install -d -m 710 -o postgres -g postgres-data \
- /run/postgresql
-
- ! getent passwd postgrey >/dev/null ||
- sudo install -d -m 2710 -o postgrey -g postfix \
- /run/postgrey
-
- sudo install -d -m 1771 -o root -g root \
- /run/spawn-fcgi
- fi
-
- ES=$?
- [ "$VERBOSE" != no ] && log_end_msg $ES
- return $ES
- fi
- }
-
-case "$1" in
- (start|restart)
- do_start
- ;;
- (reload|force-reload)
- echo "Error: argument '$1' not supported" >&2
- exit 3
- ;;
- (stop)
- ;;
- (*)
- echo "Usage: $0 start|restart|stop" >&2
- exit 3
- ;;
- esac
}
rule_dovecot_configure () {
rule apt_get_install dovecot-imapd dovecot-managesieved dovecot-sieve
- rule insserv_remove dovecot
+ rule insserv_remove dovecot
local hint="run vm_remote dovecot_key_send before"
assert "sudo test -f /etc/dovecot/\"$vm_domainname\"/imap/x509/key.pem" hint
sudo install -m 400 -o root -g root \
\$USER:\$(/usr/bin/doveadm pw -s SHA512-CRYPT):::::::
_EOF
EOF
- rule runit_sv_configure dovecot
- rule runit_sv_restart dovecot
+ rule runit_configure dovecot
}
rule_etckeeper_configure () {
sudo install -m 644 -o root -g root /dev/stdin /etc/etckeeper/etckeeper.conf <<-EOF
}
rule_insserv_remove () { # SYNTAX: $sv
local sv="$1"
- sudo chmod u+x /etc/init.d/"$sv"
+ #sudo chmod u+x /etc/init.d/"$sv"
sudo insserv --force --remove "$sv"
+ sudo test ! -x /etc/init.d/"$sv" ||
sudo /etc/init.d/"$sv" stop
sudo chmod ugo-x /etc/init.d/"$sv"
}
do test ! -d /home/git/etc/gitolite/"$d" ||
rmdir /home/git/etc/gitolite/"$d"
done
- rule tmpfs_configure
}
rule_locales_configure () {
sudo debconf-set-selections <<-EOF
}
rule_mysql_configure () {
rule apt_get_install mysql-server-5.5
- rule insserv_remove mysql
+ rule insserv_remove mysql
rule adduser mysql \
--disabled-login \
--disabled-password \
--datadir=/home/mysql/data \
--no-defaults
fi
- rule tmpfs_configure
- rule runit_sv_configure mysql
- rule runit_sv_restart mysql
+ rule runit_configure mysql
while ! sudo -u mysql mysql -u mysql </dev/null
do sleep 0.3; done
# NOTE:
test ! -r "$tool"/etc/nginx/site.d/"$site"/configure.sh ||
. "$tool"/etc/nginx/site.d/"$site"/configure.sh
done
- rule tmpfs_configure
- rule runit_sv_configure nginx
- rule runit_sv_restart nginx
+ rule runit_configure nginx
}
rule_nsd3_configure () { # NOTE: DNS autoritaire uniquement
local -; set +f
sudo install -m 640 -o root -g nsd /dev/stdin \
/etc/nsd3/nsd.conf
sudo nsdc rebuild
- rule runit_sv_configure nsd3
- rule runit_sv_restart nsd3
+ rule runit_configure nsd3
}
rule_ntp_configure () {
# NOTE: http://my.opera.com/marcomarongiu/blog/2011/01/05/independent-wallclock-in-xen-4
- rule apt_get_install ntp
- rule insserv_remove ntp
- rule runit_sv_configure ntp
- rule runit_sv_restart ntp
+ rule apt_get_install ntp
+ rule insserv_remove ntp
+ rule runit_configure ntp
}
rule_openerp_configure () {
sudo install -m 660 -o root -g root /dev/stdin /etc/apt/sources.list.d/openerp.list <<-EOF
"$tool"/etc/php5/fpm/php.ini \
/etc/php5/fpm/php.ini
done
- rule tmpfs_configure
- rule runit_sv_configure php5-fpm
- rule runit_sv_restart php5-fpm
+ rule runit_configure php5-fpm
}
rule_postfix_configure () {
local hint="run vm_remote postfix_key_send before"
"$tool"/etc/postfix/$vm_domainname/virtual_alias \
/etc/postfix/$vm_domainname/virtual_alias
sudo postmap hash:/etc/postfix/$vm_domainname/virtual_alias
- rule runit_sv_configure postfix
- rule runit_sv_restart postfix
+ rule runit_configure postfix
}
rule_postgresql_configure () {
# DOC: http://wiki.postgresql.org/wiki/Shared_Database_Hosting
rule apt_get_install postgresql-9.1
- rule insserv_remove postgresql
+ rule insserv_remove postgresql
rule adduser postgres \
--disabled-login \
--disabled-password \
/home/postgresql/log \
/home/postgresql/log/9.1 \
/home/postgresql/log/9.1/main
- rule tmpfs_configure
if sudo test ! -d /home/postgresql/data
then
sudo install -d -m 750 -o postgres -g postgres \
sudo install -m 640 -o postgres -g postgres-data \
"$tool"/etc/postgresql/9.1/main/postgresql.conf \
/etc/postgresql/9.1/main/postgresql.conf
- rule runit_sv_configure postgres
- rule runit_sv_restart postgres
+ rule runit_configure postgres
while ! sudo -u postgres psql </dev/null
do sleep 1; done
# NOTE: supprime l'accès au schéma public depuis public,
rule_postgrey_configure () {
rule apt_get_install postgrey
rule insserv_remove postgrey
- rule tmpfs_configure
- rule runit_sv_configure postgrey
- rule runit_sv_restart postgrey
+ rule runit_configure postgrey
}
rule_procmail_configure () {
rule apt_get_install procmail
"$tool"/etc/skel/etc/mail/delivery.procmailrc \
/etc/skel/etc/mail/delivery.procmailrc
}
-rule_runit_configure () { # SYNTAX: $service
+rule_runit_configure () { # SYNTAX: $sv
rule apt_get_install runit
local -; set +f
- for sv in ${1-/etc/service/*}
- # NOTE: stoppe les services en retenant leur status de départ
- do sv=${sv##*/}
- local sv_hash=$(printf %s "$sv" | sha1sum | cut -f 1 -d ' ')
- local sv_status
- IFS= read -r sv_status_$sv_hash <<-EOF
- $(sudo sv status "$sv" || true)
- EOF
- sudo rm -f /etc/service/"$sv"
- done
+ sudo find /etc/sv -mindepth 1 -maxdepth 1 -type d -name "${1:-*}" -exec \
+ /bin/sh -efux -c 'case $(sv stop "$1") in
+ (*": runsv not running") true;;
+ (*": unable to open supervise/ok: file does not exist") true;;
+ ("ok: down:"*) true;;
+ (*) false;;
+ esac' '' {} +
set -$- ${1-"$tool"/etc/sv/*}
while test -n "$*"
- # NOTE: configure et (re-)démarre les services
do local first=yes
for sv in "$@"
do sv=${sv##*/}
case $first in
(yes) shift $#; first=;;
esac
- local sv_hash=$(printf %s "$sv" | sha1sum | cut -f 1 -d ' ')
- rule runit_sv_configure "$sv"
- eval local sv_status=\"\${sv_status_$sv_hash-}\"
- case $sv_status in
- ("") true;;
- (run:*|fail:*) rule runit_sv_restart "$sv";;
- esac
+ rule _runit_sv_configure "$sv"
+ rule runit_sv_restart "$sv"
done
done
+ sudo find -L /etc/service -type l -delete
}
-rule_runit_sv_configure () { # SYNTAX: $sv
+rule__runit_sv_configure () { # SYNTAX: $sv
local sv="$1"
sudo install -d -m 770 -o root -g root \
/etc/sv/"$sv"
}
rule_runit_sv_restart () { # SYNTAX: $sv
local sv="$1"
- rule runit_sv_configure "$sv"
while true
do case $(sudo sv restart "$sv") in
("fail: $sv: runsv not running") sleep 1;;
sudo install -m 644 -o root -g root \
"$tool"/etc/ssh/ssh_config \
/etc/ssh/ssh_config
- rule runit_sv_configure sshd
- rule runit_sv_restart sshd
+ rule runit_configure sshd
}
rule_sysctl_configure () {
local -; set +f
TMP_SIZE=200m
TMPFS_SIZE=20%VM
EOF
- sudo install -m 775 -o root -g root \
- "$tool"/etc/init.d/tmpfs \
- /etc/init.d/tmpfs
- sudo update-rc.d tmpfs defaults
- sudo service tmpfs restart
}
rule_time_configure () {
sudo install -m 644 -o root -g root /dev/stdin /etc/timezone <<-EOF
}
rule_unbound_configure () {
sudo apt-get install unbound
- rule insserv_remove unbound
+ rule insserv_remove unbound
sudo install -m 644 -o root -g root /dev/stdin /etc/resolv.conf <<-EOF
search ${vm_host#*.}
nameserver 127.0.0.1
<"$tool"/etc/unbound/unbound.conf |
sudo install -m 440 -o unbound -g unbound /dev/stdin \
/etc/unbound/unbound.conf
- rule runit_sv_configure unbound
- rule runit_sv_restart unbound
+ rule runit_configure unbound
}
rule_user_add () { # SYNTAX: $user
local user="$1"; shift